import {
  BwComPropSetConstValueComEnum,
  BwCustomComPropDataTypeEnum,
  BwCustomComEmitParamDataTypeEnum,
  BwCustomComSoltTypeEnum,
} from '../../../render/models'
import type {
  BwCustomComEmitInfoModel,
  BwCustomComSlotInfoModel,
  BwCustomComPropInfoModel,
} from '../../../render/models'

/** 组件属性 */
const comAttrs: Array<BwCustomComPropInfoModel> = [
  {
    key: 'class',
    name: 'classNames',
    isRequire: false,
    defaultValue: undefined,
    dataType: [
      BwCustomComPropDataTypeEnum.string,
      BwCustomComPropDataTypeEnum.array,
    ],
    defaultValueDataType: BwCustomComPropDataTypeEnum.string,
    constValueSetCom: BwComPropSetConstValueComEnum.input,
    constValueSetComProps: null,
    remark: '',
  },
  {
    key: 'current',
    name: '当前页数(v-model)',
    isRequire: false,
    isModel: true,
    defaultValue: undefined,
    dataType: [BwCustomComPropDataTypeEnum.number],
    defaultValueDataType: BwCustomComPropDataTypeEnum.number,
    constValueSetCom: BwComPropSetConstValueComEnum.number,
    constValueSetComProps: null,
    remark: '',
  },
  {
    key: 'defaultPageSize',
    name: '默认的每页条数',
    isRequire: false,
    defaultValue: '10',
    dataType: [BwCustomComPropDataTypeEnum.number],
    defaultValueDataType: BwCustomComPropDataTypeEnum.number,
    constValueSetCom: BwComPropSetConstValueComEnum.number,
    constValueSetComProps: null,
    remark: '',
  },
  {
    key: 'disabled',
    name: '禁用分页',
    isRequire: false,
    defaultValue: 'false',
    dataType: [BwCustomComPropDataTypeEnum.boolean],
    defaultValueDataType: BwCustomComPropDataTypeEnum.boolean,
    constValueSetCom: BwComPropSetConstValueComEnum.switch,
    constValueSetComProps: null,
    remark: '',
  },
  {
    key: 'hideOnSinglePage',
    name: '只有一页时是否隐藏分页器',
    isRequire: false,
    defaultValue: 'false',
    dataType: [BwCustomComPropDataTypeEnum.boolean],
    defaultValueDataType: BwCustomComPropDataTypeEnum.boolean,
    constValueSetCom: BwComPropSetConstValueComEnum.switch,
    constValueSetComProps: null,
    remark: '',
  },
  {
    key: 'itemRender',
    name: '用于自定义页码的结构，可用于优化 SEO',
    isRequire: false,
    defaultValue: undefined,
    dataType: [BwCustomComPropDataTypeEnum.string],
    defaultValueDataType: BwCustomComPropDataTypeEnum.string,
    constValueSetCom: BwComPropSetConstValueComEnum.select,
    constValueSetComProps: JSON.stringify({
      options: [
        {
          label: 'page',
          value: 'page',
        },
        {
          label: 'prev',
          value: 'prev',
        },
        {
          label: 'next',
          value: 'next',
        },
      ],
    }),
    remark: '',
  },
  {
    key: 'pageSize',
    name: '每页条数(v-model)',
    isRequire: false,
    isModel: true,
    defaultValue: '10',
    dataType: [BwCustomComPropDataTypeEnum.number],
    defaultValueDataType: BwCustomComPropDataTypeEnum.number,
    constValueSetCom: BwComPropSetConstValueComEnum.number,
    constValueSetComProps: null,
    remark: '',
  },
  {
    key: 'pageSizeOptions',
    name: '指定每页可以显示多少条',
    isRequire: false,
    defaultValue: JSON.stringify([10, 20, 50, 100]),
    dataType: [BwCustomComPropDataTypeEnum.array],
    defaultValueDataType: BwCustomComPropDataTypeEnum.array,
    constValueSetCom: BwComPropSetConstValueComEnum.textarea,
    constValueSetComProps: null,
    remark: '',
  },
  {
    key: 'responsive',
    name: '当 size 未指定时，根据屏幕宽度自动调整尺寸',
    isRequire: false,
    defaultValue: 'false',
    dataType: [BwCustomComPropDataTypeEnum.boolean],
    defaultValueDataType: BwCustomComPropDataTypeEnum.boolean,
    constValueSetCom: BwComPropSetConstValueComEnum.switch,
    constValueSetComProps: null,
    remark: '',
  },
  {
    key: 'showLessItems',
    name: '是否显示较少页面内容',
    isRequire: false,
    defaultValue: 'false',
    dataType: [BwCustomComPropDataTypeEnum.boolean],
    defaultValueDataType: BwCustomComPropDataTypeEnum.boolean,
    constValueSetCom: BwComPropSetConstValueComEnum.switch,
    constValueSetComProps: null,
    remark: '',
  },
  {
    key: 'showQuickJumper',
    name: '是否可以快速跳转至某页',
    isRequire: false,
    defaultValue: 'false',
    dataType: [BwCustomComPropDataTypeEnum.boolean],
    defaultValueDataType: BwCustomComPropDataTypeEnum.boolean,
    constValueSetCom: BwComPropSetConstValueComEnum.switch,
    constValueSetComProps: null,
    remark: '',
  },
  {
    key: 'showSizeChanger',
    name: '是否展示 pageSize 切换器，当 total 大于 50 时默认为 true',
    isRequire: false,
    defaultValue: undefined,
    dataType: [BwCustomComPropDataTypeEnum.boolean],
    defaultValueDataType: BwCustomComPropDataTypeEnum.boolean,
    constValueSetCom: BwComPropSetConstValueComEnum.switch,
    constValueSetComProps: null,
    remark: '',
  },
  {
    key: 'showTotal',
    name: '用于显示数据总量和当前数据顺序',
    isRequire: false,
    defaultValue: undefined,
    dataType: [BwCustomComPropDataTypeEnum.string],
    defaultValueDataType: BwCustomComPropDataTypeEnum.string,
    constValueSetCom: BwComPropSetConstValueComEnum.textarea,
    constValueSetComProps: null,
    remark: '',
  },
  {
    key: 'simple',
    name: '当添加该属性时，显示为简单分页',
    isRequire: false,
    defaultValue: undefined,
    dataType: [BwCustomComPropDataTypeEnum.boolean],
    defaultValueDataType: BwCustomComPropDataTypeEnum.boolean,
    constValueSetCom: BwComPropSetConstValueComEnum.switch,
    constValueSetComProps: null,
    remark: '',
  },
  {
    key: 'size',
    name: '当为 small 时，是小尺寸分页',
    isRequire: false,
    defaultValue: 'default',
    dataType: [BwCustomComPropDataTypeEnum.string],
    defaultValueDataType: BwCustomComPropDataTypeEnum.string,
    constValueSetCom: BwComPropSetConstValueComEnum.select,
    constValueSetComProps: JSON.stringify({
      options: [
        {
          label: '默认',
          value: 'default',
        },
        {
          label: '最小',
          value: 'small',
        },
      ],
    }),
    remark: '',
  },
  {
    key: 'total',
    name: '数据总数',
    isRequire: false,
    defaultValue: '0',
    dataType: [BwCustomComPropDataTypeEnum.number],
    defaultValueDataType: BwCustomComPropDataTypeEnum.number,
    constValueSetCom: BwComPropSetConstValueComEnum.number,
    constValueSetComProps: null,
    remark: '',
  },
]

/** 组件事件 */
const comEmits: Array<BwCustomComEmitInfoModel> = [
  {
    key: 'update:current',
    name: 'update:current',
    isModel: true,
    params: [
      {
        paramKey: 'current',
        paramName: 'current',
        paramDataType: BwCustomComEmitParamDataTypeEnum.number,
        remark: '',
      },
    ],
  },
  {
    key: 'update:pageSize',
    name: 'update:pageSize',
    isModel: true,
    params: [
      {
        paramKey: 'pageSize',
        paramName: 'pageSize',
        paramDataType: BwCustomComEmitParamDataTypeEnum.number,
        remark: '',
      },
    ],
  },
  {
    key: 'change',
    name: '页码或 pageSize 改变的回调，参数是改变后的页码及每页条数',
    params: [
      {
        paramKey: 'page',
        paramName: '页码',
        paramDataType: BwCustomComEmitParamDataTypeEnum.number,
        remark: '',
      },
      {
        paramKey: 'pageSize',
        paramName: '每页条数',
        paramDataType: BwCustomComEmitParamDataTypeEnum.number,
        remark: '',
      },
    ],
  },
  {
    key: 'showSizeChange',
    name: 'pageSize 变化的回调',
    params: [
      {
        paramKey: 'current',
        paramName: '当前页数',
        paramDataType: BwCustomComEmitParamDataTypeEnum.number,
        remark: '',
      },
      {
        paramKey: 'size',
        paramName: '每页条数',
        paramDataType: BwCustomComEmitParamDataTypeEnum.number,
        remark: '',
      },
    ],
  },
]

/** 组件插槽 */
const comSlots: Array<BwCustomComSlotInfoModel> = [
  {
    slotType: BwCustomComSoltTypeEnum.convention,
    conventionSlotInfo: {
      slotCode: 'itemRender',
      slotName: '用于自定义页码的结构，可用于优化 SEO',
    },
  },
  {
    slotType: BwCustomComSoltTypeEnum.convention,
    conventionSlotInfo: {
      slotCode: 'default',
      slotName: '默认插槽',
    },
  },
]

export const antPaginationInfo = {
  comAttrs,
  comEmits,
  comSlots,
}
